import requests
from cdp_error_service.get_cdp_token import upm_token_server


# 示例使用逻辑
def main_logic():
    url = 'https://www.cdp.changan.com.cn/tag-system/api/mergeobject/tag/553/execute'
    method = "POST"
    read_timeout = 30  # 读取超时（秒）
    connect_timeout = 30  # 连接超时（秒）
    data = {"key": "value"}  # 请求数据，替换为实际数据

    if upm_token_server.verify_token():
        upm_token = upm_token_server.get_redis_token()
        if not upm_token:
            print("token获取失败")
        else:
            head_map = upm_token.get_head_map()
            cookie_map = upm_token.get_cookie_map()
            response = requests.put(url, headers=head_map, cookies=cookie_map, json=data)


            print(f"HTTP Response: {response.status_code} {response.text}")
    else:
        print("token授权失败")


if __name__ == "__main__":
    main_logic()
